/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
 * adlglue.h
 *
 * description here
 *
 */
#ifndef ADLGLUE_H
#define ADLGLUE_H

/* must the same with LOCK_XXX in ocfs2_lockglue.h */
#define ADL_LOCK_IV		0
#define ADL_LOCK_NL		0
#define ADL_LOCK_PR		3
#define ADL_LOCK_EX		5

extern const struct ocfs2_lockglue_ops adl_lock_ops;

/* 4K block can has maximum 8 adl sectors */
#define ADL_INVALID_OFFSET	8

enum adl_refcount_lock_offset {
	ADL_REFCOUNT_LOCK_OFFSET = 0,
};

enum adl_local_lock_offset {
	ADL_INODE_LOCK_OFFSET = 0,
	ADL_OPEN_LOCK_OFFSET,
	ADL_RW_LOCK_OFFSET,
	ADL_FILE_LOCK_OFFSET,
	ADL_QUOTA_LOCK_OFFSET,
};

enum adl_global_lock_offset {
	ADL_SUPER_LOCK_OFFSET = 0,
	ADL_RENAME_LOCK_OFFSET,
	ADL_NFS_SYNC_LOCK_OFFSET,
	ADL_ORPHAN_SCAN_LOCK_OFFSET,
	ADL_SUPER_BLOCK_LOCK_OFFSET,
	ADL_USER_INIT_LOCKFS_LOCK_OFFSET,
	ADL_USER_RESIZE_LOCK_OFFSET,
	ADL_USER_MAP_TABLE_LOCK_OFFSET,
};

/* copy from stackglue.h */
#define GROUP_NAME_MAX	64

struct ocfs2_adl_cluster_connection {
	char cc_name[GROUP_NAME_MAX];
	int cc_namelen;
	struct adl_net_request_cb cc_unlock_lock_cb;
	struct adl_net_request_cb cc_query_lock_cb;
	struct adl_net_request_cb cc_release_truncate_log_cb;
	void (*cc_recovery_handler)(int node_num, void *recovery_data);
	void *cc_recovery_data;
	void *cc_lockspace;
	void *cc_private;
};

int ocfs2_adl_cluster_connect(const char *domain_name,
				int domain_len,
				void (*recovery_handler)(int node_num, void *recovery_data),
				void *recovery_data,
				struct ocfs2_adl_cluster_connection **conn,
				struct block_device *bdev);
void ocfs2_adl_cluster_disconnect(struct ocfs2_adl_cluster_connection *conn);

#endif	/* ADLGLUE_H */
